package com.yanqu.road.server.cmd.activity.peakstronghold.cross;

import com.yanqu.road.entity.activity.peakstronghold.UserPeakStrongholdPatronsData;
import com.yanqu.road.entity.activity.peakstronghold.config.PeakStrongHoldConfig;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.log.LogPeakHoldAttack;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PeakStrongholdWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.peakstronghold.PeakStrongholdModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.PreReduceModule;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.peakstronghold.PeakStrongholdActivityMgr;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.union.GameUnionActivityGroupMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.math.BigInteger;

@Cmd(code = GameProtocol.S_PEAKSTRONGHOLD_MAMMON_HELP_NOTICE, desc = "巅峰据点战财神助力广播")
public class CrossPeakStrongholdMammonHelpNoticeCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        PeakStrongHoldConfig config = PeakStrongholdActivityMgr.getConfig();
        if (config == null || !ActivityMgr.activityInShowTime(config.getActivityInfo())) {
            return;
        }
        int activityId = config.getActivityInfo().getActivityId();
        PeakStrongholdWarProto.PeakStrongholdNoticeMammonHelpGroupMsg groupMsg = PeakStrongholdWarProto.PeakStrongholdNoticeMammonHelpGroupMsg.parseFrom(packet.getBytes());
        if (groupMsg.getActivityId() != activityId) {
            return;
        }

        for (GamePlayer onlinePlayer : GamePlayerMgr.getAllOnlinePlayer()) {
            int playerGroup = GameUnionActivityGroupMgr.getGroupId(activityId, onlinePlayer.getUserId());
            if (playerGroup == groupMsg.getUnionGroup()) {
                onlinePlayer.sendPacket(ClientProtocol.U_PEAK_STRONGHOLD_MAMMON_HELP_NOTICE, groupMsg.getMsg().toBuilder());
            }
        }

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
